﻿<UserControl x:Class="DebIt.View.UserControls.LoanControl"
             x:Name="LoanCtrl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converters="clr-namespace:DebIt.Converter"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="293" d:DesignWidth="552">

    <UserControl.Resources>
        <converters:DateConverter x:Key="DateConverter"/>
    </UserControl.Resources>

    <Border x:Name="boMain" BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="3" Margin="8">
        <Grid x:Name="grMain" Margin="-3" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="80"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition Height="25"/>
                <RowDefinition Height="25"/>
                <RowDefinition Height="Auto" MinHeight="8"/>
            </Grid.RowDefinitions >
            <TextBlock x:Name="tbName" TextWrapping="Wrap"  FontSize="32" Margin="8,0" Text="{Binding Name}" VerticalAlignment="Center" FontWeight="Bold"/>
            <StackPanel x:Name="spValue" Grid.Row="1" Orientation="Horizontal" Margin="8,0">
                <TextBlock x:Name="tbValName" TextWrapping="Wrap" Text="{Binding Path=LocalizedResources.st_descr_value, Source={StaticResource LocalizedStrings}}"  FontSize="18.667" VerticalAlignment="Top"/>
                <TextBlock x:Name="tbVal" TextWrapping="Wrap" Text="{Binding LoanValue}"  FontSize="18.667" VerticalAlignment="Top"/>
                <TextBlock x:Name="tbConcur" TextWrapping="Wrap" Text="{Binding Currency}"  FontSize="18.667" VerticalAlignment="Top" Margin="8,0,0,0"/>
            </StackPanel>
            <StackPanel x:Name="spDate" Grid.Row="2" Orientation="Horizontal" Margin="8,0">
                <TextBlock x:Name="tbDateName" TextWrapping="Wrap" Text="{Binding LocalizedResources.st_descr_date, Source={StaticResource LocalizedStrings}}"  HorizontalAlignment="Left" FontSize="18.667" VerticalAlignment="Top"/>
                <TextBlock x:Name="tbDate" TextWrapping="Wrap" Text="{Binding TimeStamp, Converter={StaticResource DateConverter}}"  HorizontalAlignment="Left" FontSize="18.667" VerticalAlignment="Top"/>
            </StackPanel>
            <Button x:Name="btnEdit" Grid.Column="1" BorderBrush="Transparent" Foreground="Transparent" Grid.RowSpan="2" VerticalAlignment="Bottom" Height="75" Click="BtnEditClick" BorderThickness="0">
                <Image x:Name="imgEdit" Source="../../icons/dark/edit.png"
                    Height="75"
                    Width="75"  HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Button>
            <Button x:Name="btnDelete" Grid.Column="1" BorderBrush="Transparent" Foreground="Transparent"  Command="{Binding ElementName=LoanCtrl, Path=DeletLoanCommand}" CommandParameter="{Binding}" BorderThickness="0" Grid.Row="3" Height="75" VerticalAlignment="Top" Margin="0,-25,0,0" d:LayoutOverrides="VerticalAlignment">
                <Image x:Name="imgDelete" Source="../../icons/dark/delete.png"
            		Height="75"
            		Width="75"  HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Button>
            <StackPanel x:Name="spDetails" Margin="8,0,0,0" Grid.Row="3">
                <TextBlock TextWrapping="Wrap" Text="{Binding LocalizedResources.st_cuc_friends, Source={StaticResource LocalizedStrings}}"  FontWeight="Bold" Margin="0,0,8,0" FontSize="24"/>
                <ListBox  ItemsSource="{Binding ClientLoanStates}" ScrollViewer.VerticalScrollBarVisibility="Disabled" d:LayoutOverrides="VerticalAlignment">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Width="520">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="0.35*"/>
                                    <ColumnDefinition Width="0.65*"/>
                                </Grid.ColumnDefinitions>
                                <CheckBox IsChecked="{Binding IsPaid, Mode=TwoWay}" Command="{Binding LoanPaiedChange, ElementName=LoanCtrl}" CommandParameter="{Binding}"/>
                                <StackPanel Orientation="Horizontal" Grid.Column="1" VerticalAlignment="Center">
                                    <TextBlock TextWrapping="Wrap" Text="{Binding Client.FirstName}" VerticalAlignment="Center"  d:LayoutOverrides="Width" Margin="0,4,0,4"/>
                                    <TextBlock TextWrapping="Wrap" Text="{Binding Client.LastName}" VerticalAlignment="Center"  d:LayoutOverrides="Width" Margin="8,4,0,4"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Grid.Column="2" VerticalAlignment="Center">
                                    <TextBlock TextWrapping="Wrap" Text="{Binding Loan.LoanPerClient}" VerticalAlignment="Center"  d:LayoutOverrides="Width" Margin="0,4,0,4" />
                                    <TextBlock TextWrapping="Wrap" Text="{Binding Loan.Currency}" VerticalAlignment="Center"  d:LayoutOverrides="Width" Margin="8,4,0,4" />
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <TextBlock TextWrapping="Wrap" Text="{Binding LocalizedResources.st_cuc_loan_items, Source={StaticResource LocalizedStrings}}" Margin="0,0,-8,0" FontWeight="Bold" Height="30" FontSize="24" />
                <ListBox Width="448" Margin="0,0,-8,12" ItemsSource="{Binding LoanItems}"  ScrollViewer.VerticalScrollBarVisibility="Disabled" d:LayoutOverrides="VerticalAlignment">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Width="520">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.35*"/>
                                    <ColumnDefinition Width="0.65*"/>
                                </Grid.ColumnDefinitions>
                                <StackPanel Orientation="Horizontal" Grid.Column="0" VerticalAlignment="Center">
                                    <TextBlock TextWrapping="Wrap" Text="{Binding Description}" VerticalAlignment="Center"  d:LayoutOverrides="Width" Margin="8,4,0,4"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Grid.Column="1" VerticalAlignment="Center">
                                    <TextBlock TextWrapping="Wrap" Text="{Binding Value}" VerticalAlignment="Center"  d:LayoutOverrides="Width" Margin="0,4,0,4" />
                                    <TextBlock TextWrapping="Wrap" Text="{Binding Loan.Currency}" VerticalAlignment="Center"  d:LayoutOverrides="Width" Margin="8,4,0,4" />
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </StackPanel>
            <Button Content="Button" Margin="8,8,0,0" Grid.RowSpan="3" Opacity="0" Tap="BtnTapTapped" />
            <Button Content="Button" Margin="62,59,0,-118" Opacity="0" Tap="BtnTapTapped" Grid.Row="3" Grid.ColumnSpan="2" />
        </Grid>
    </Border>
</UserControl>
